package com.net.oil.user;

import android.os.Bundle;
import androidx.viewpager.widget.ViewPager;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.android.material.tabs.TabLayout;
import com.net.oil.R;
import com.net.oil.user.adapter.MyReceiveGoodsViewPagerAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MyReceiveGoodsActivity extends AppCompatActivity {

    @BindView(R.id.toolbar_go_back)
    ImageView toolbarGoBack;
    @BindView(R.id.toolbar_title)
    TextView toolbarTitle;
    @BindView(R.id.tab_layout)
    TabLayout tabLayout;
    @BindView(R.id.view_pager)
    ViewPager viewPager;

    private String[] tabName;
    private MyReceiveGoodsViewPagerAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_receive_goods);
        ButterKnife.bind(this);
        initData();
        initView();
    }

    private void initData() {
        tabName = getResources().getStringArray(R.array.receive_tab_name);
    }

    private void initView() {
        toolbarTitle.setText("我领取的商品");

        viewPager.setOffscreenPageLimit(2);
        adapter = new MyReceiveGoodsViewPagerAdapter(getSupportFragmentManager(), tabName);
        viewPager.setAdapter(adapter);

        tabLayout.setupWithViewPager(viewPager);
        viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    }

    @OnClick(R.id.toolbar_go_back)
    public void onViewClicked() {
        finish();
    }
}
